Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Por qué esta página next.js y mecanografiada dice "La propiedad 'datos' no existe en el tipo"

Estoy empezando a usar mecanografiado con next.js

 const Index: NextPage = (props) => { return (<p>{prop.data.name}</p>); } export default Index; export const getServerSideProps = async () => { const data = await fetch( `${server}/api` ).then((response) => response.json()); return { props: {data} }; };

mi editor resalta la palabra data en {props.data.name} con este mensaje

 Property 'data' does not exist on type '{ children?: ReactNode; }'.

¿Cómo puedo definir un tipo de esto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe definir un tipo y pasarlo al parámetro genérico de NextPage como se muestra a continuación

 type PictureType = { category: string, createdAt: string, favourites: number, isHidden: boolean, title: string, updatedAt: string, url: string, user: string, } type ResponseDataType = { lastPictures: PictureType[], picturesByCat: PictureType[] } type PageProps = { data: ResponseDataType, } const Index: NextPage<PageProps> = (props) => { return (<p>{prop.data.name}</p>); } export default Index; export const getServerSideProps = async () => { const data = await fetch( `${server}/api` ).then((response) => response.json()); return { props: {data} }; };
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!